package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.data.interfaces.IFenSiInterface;
import com.itboye.mengwu.data.model.FenSiBean;
import com.itboye.mengwu.data.model.MessgeBean;
import com.itboye.mengwu.data.repository.FenSiRepository;

public class FenSiPresenter extends BasePresenter implements
		IFenSiInterface<FenSiBean> {

	public static final String FenSiSuccess = "FenSiSuccess";
	public static final String FenSiFail = "FenSIFail";

	/**
	 * 系统通知
	 * 
	 * @param observer
	 */
	public static final String MessageSuccess = "FenSiSuccess";
	public static final String MessageFail = "FenSIFail";
	/**
	 * 商品赠送
	 * 
	 * @param observer
	 */
	public static final String ShopSuccess = "FenSiSuccess";
	public static final String ShopFail = "FenSIFail";

	/**
	 * 我收到的
	 * 
	 * @param observer
	 */
	public static final String ShouDaoccess = "FenSiSuccess";
	public static final String ShouDaoFail = "FenSIFail";

	public FenSiPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(FenSiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(FenSiBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(FenSiBean model) {
		// TODO Auto-generated method stub
		IFenSiInterface<FenSiBean> redBag = new FenSiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(FenSiSuccess);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(FenSiFail);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.update(model);
	}

	@Override
	public void getInfo(FenSiBean model) {
		// TODO Auto-generated method stub
		// 我的帖子
		IFenSiInterface<FenSiBean> redBag = new FenSiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(FenSiSuccess);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(FenSiFail);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.getInfo(model);
	}

	@Override
	public List<FenSiBean> query(FenSiBean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void systemMessage(String uid, String msgType,int pageNo) {
		// TODO Auto-generated method stub
		IFenSiInterface<FenSiBean> redBag = new FenSiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(MessageSuccess);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(MessageFail);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.systemMessage(uid, msgType,pageNo);
	}

	@Override
	public void ShopZengSong(String uid, String page_no, String page_size) {
		// TODO Auto-generated method stub
		IFenSiInterface<FenSiBean> redBag = new FenSiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(ShopSuccess);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShopFail);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.ShopZengSong(uid, page_no, page_size);
	}

	@Override
	public void onMeShouDao(String to_uid, String page_no, String page_size) {
		// TODO Auto-generated method stub
		IFenSiInterface<FenSiBean> redBag = new FenSiRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(ShouDaoccess);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShouDaoFail);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.onMeShouDao(to_uid, page_no, page_size);
	}

}
